package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.pojo.CheckItem;
import com.itheima.response.Result;
import com.itheima.resquest.QueryPageBean;
import com.itheima.service.CheckItemService;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/checkItem")
public class CheckItemController {
    @Reference
    private CheckItemService checkItemService;

    @GetMapping("/findAll")
    public Result findAll(){
        return checkItemService.findAll();
    }

    //    根据条件查询带分页
    @GetMapping("/search")
    public Result search(@RequestBody QueryPageBean queryPageBean){
        return checkItemService.search(queryPageBean);
    };
    //    根据Id查询
    @GetMapping("findOne")
    public Result<CheckItem> findOne(@RequestParam("id") Integer id){
        return checkItemService.findOne(id);
    };
    //    根据Id修改
    @PutMapping
    public Result<CheckItem> edit(@RequestParam("id") Integer id,@RequestBody CheckItem checkItem){
        return checkItemService.edit(id,checkItem);
    };
    //    新增
    @PostMapping
    public Result<CheckItem> add(@RequestBody CheckItem checkItem){
        return checkItemService.add(checkItem);
    };
    //    删除
    @DeleteMapping
    public Result delete(@RequestParam("id") Integer id){
        return checkItemService.delete(id);
    };
}
